<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>utterances 用做博客评论 - Lucklyの博客 - 在阅读中遇见自己</title>
    <meta name="renderer" content="webkit" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>

<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />

<meta name="theme-color" content="#f8f5ec" />
<meta name="msapplication-navbutton-color" content="#f8f5ec">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="#f8f5ec">


<meta name="author" content="Luckly" /><meta name="description" content="utterances 是一款基于 GitHub issues 的评论工具。
相比同类的工具 gitment、gitalk 以及 disqus 评论工具，优点如下：
 极其轻量 加载非常快 配置比较简单 " /><meta name="keywords" content="Hugo, theme, even" />






<meta name="generator" content="Hugo 0.79.1 with even 4.0.0" />


<link rel="canonical" href="https://luckly.work/2019/05/utterances-%E7%94%A8%E5%81%9A%E5%8D%9A%E5%AE%A2%E8%AF%84%E8%AE%BA/" />
<link href="/2019/05/utterances-%E7%94%A8%E5%81%9A%E5%8D%9A%E5%AE%A2%E8%AF%84%E8%AE%BA/" rel="alternate" type="application/rss+xml" title="Lucklyの博客 - 在阅读中遇见自己" />
<link href="/2019/05/utterances-%E7%94%A8%E5%81%9A%E5%8D%9A%E5%AE%A2%E8%AF%84%E8%AE%BA/" rel="feed" type="application/rss+xml" title="Lucklyの博客 - 在阅读中遇见自己" />
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
<link rel="manifest" href="/manifest.json">
<link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5">

<script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
<link href="/dist/even.06658218.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3.1.20/dist/jquery.fancybox.min.css" integrity="sha256-7TyXnr2YU040zfSP+rEcz29ggW4j56/ujTPwjMzyqFY=" crossorigin="anonymous">
<link rel="stylesheet" href="/css/reset-even.css">


<meta property="og:title" content="utterances 用做博客评论" />
<meta property="og:description" content="utterances 是一款基于 GitHub issues 的评论工具。
相比同类的工具 gitment、gitalk 以及 disqus 评论工具，优点如下：

极其轻量
加载非常快
配置比较简单
" />
<meta property="og:type" content="article" />
<meta property="og:url" content="https://luckly.work/2019/05/utterances-%E7%94%A8%E5%81%9A%E5%8D%9A%E5%AE%A2%E8%AF%84%E8%AE%BA/" />
<meta property="article:published_time" content="2019-05-04T11:10:56+08:00" />
<meta property="article:modified_time" content="2019-05-04T11:10:56+08:00" />
<meta itemprop="name" content="utterances 用做博客评论">
<meta itemprop="description" content="utterances 是一款基于 GitHub issues 的评论工具。
相比同类的工具 gitment、gitalk 以及 disqus 评论工具，优点如下：

极其轻量
加载非常快
配置比较简单
">
<meta itemprop="datePublished" content="2019-05-04T11:10:56+08:00" />
<meta itemprop="dateModified" content="2019-05-04T11:10:56+08:00" />
<meta itemprop="wordCount" content="445">



<meta itemprop="keywords" content="" />
<meta name="twitter:card" content="summary"/>
<meta name="twitter:title" content="utterances 用做博客评论"/>
<meta name="twitter:description" content="utterances 是一款基于 GitHub issues 的评论工具。
相比同类的工具 gitment、gitalk 以及 disqus 评论工具，优点如下：

极其轻量
加载非常快
配置比较简单
"/>

</head>
<body>
<div id="mobile-navbar" class="mobile-navbar">
    <div class="mobile-header-logo">
        <a href="/" class="logo">遇见</a>
    </div>
    <div class="mobile-navbar-icon">
        <span></span>
        <span></span>
        <span></span>
    </div>
</div>
<nav id="mobile-menu" class="mobile-menu slideout-menu">
    <ul class="mobile-menu-list">
        <a href="/">
            <li class="mobile-menu-item" title="首页">首页</li>
        </a>
        <a href="/post/">
            <li class="mobile-menu-item" title="归档">归档</li>
        </a>
        <a href="/categories/">
            <li class="mobile-menu-item" title="分类">分类</li>
        </a>
        <a href="/tags/">
            <li class="mobile-menu-item" title="标签">标签</li>
        </a>
        <a href="/about/">
            <li class="mobile-menu-item" title="关于我">关于我</li>
        </a>
        <a href="/friend/">
            <li class="mobile-menu-item" title="友链">友链</li>
        </a>
        <a href="https://github.com/ITmxs/">
            <li class="mobile-menu-item" title="阅读清单">阅读清单</li>
        </a>
        
    </ul>
    <form class="search-form" style="position: absolute;">
    <input name="search" type="search" style="height: 28px;padding-left: 30px;"/>
    <input type="image" src="/img/search.svg" alt="Search" style="position: absolute;left: 6px;top: 6px;"/>
</form>


</nav>

<div class="container" id="mobile-panel">
    <header id="header" class="header">
        <div class="logo-wrapper">
  <a href="/%20/" class="logo">遇见</a>
</div>

<nav class="site-navbar">
  <ul id="menu" class="menu">
    <li class="menu-item">
      <a class="menu-item-link" href="/">首页</a>
    </li><li class="menu-item">
      <a class="menu-item-link" href="/post/">归档</a>
    </li><li class="menu-item">
      <a class="menu-item-link" href="/categories/">分类</a>
    </li><li class="menu-item">
      <a class="menu-item-link" href="/tags/">标签</a>
    </li><li class="menu-item">
      <a class="menu-item-link" href="/about/">关于我</a>
    </li><li class="menu-item">
      <a class="menu-item-link" href="/friend/">友链</a>
    </li><li class="menu-item">
      <a class="menu-item-link" href="https://github.com/ITmxs/">阅读清单</a>
    </li>
  </ul>
</nav>
        <form class="search-form" style="position: absolute;">
    <input name="search" type="search" style="height: 28px;padding-left: 30px;"/>
    <input type="image" src="/img/search.svg" alt="Search" style="position: absolute;left: 6px;top: 6px;"/>
</form>



    </header>


    <main id="main" class="main">
        <div class="content-wrapper">
            <div id="content" class="content">
                <article class="post">
  
  <header class="post-header">
    <h1 class="post-title">utterances 用做博客评论</h1>

    <div class="post-meta">
      <span class="post-time"> 2019-05-04 </span>
      
      <span class="more-meta"> 约 445 字 </span>
      <span class="more-meta"> 预计阅读 1 分钟 </span>
      <span id="busuanzi_container_page_pv" class="more-meta"> <span id="busuanzi_value_page_pv"><img src="/img/spinner.svg" alt="spinner.svg"/></span> 次阅读 </span>
    </div>
  </header>

  <div class="post-toc" id="post-toc">
  <h2 class="post-toc-title">文章目录</h2>
  <div class="post-toc-content">
    <nav id="TableOfContents">
  <ul>
    <li>
      <ul>
        <li><a href="#安装-utterances">安装 utterances</a></li>
        <li><a href="#使用-utterances">使用 utterances</a></li>
        <li><a href="#配置-utterances">配置 utterances</a></li>
      </ul>
    </li>
  </ul>
</nav>
  </div>
</div>
  <div class="post-content">
    <p><a href="https://github.com/utterance/utterances">utterances</a> 是一款基于 GitHub issues 的评论工具。</p>
<p>相比同类的工具 gitment、gitalk 以及 disqus 评论工具，优点如下：</p>
<ol>
<li>极其轻量</li>
<li>加载非常快</li>
<li>配置比较简单</li>
</ol>
<p>博之前客一直使用 disqus ,这个工具配置也比较简单，也是免费的。但是，广告多，而且加载也比较慢。</p>
<p>体验了一把 utterances 后，马上切换到 utterances。</p>
<h2 id="安装-utterances">安装 utterances</h2>
<p>utterances 的安装相当简单，因为出品了一个 Github App。</p>
<p>首先安装这个 App ，选择要关联评论的仓库。可以选择所有仓库，也可以只选择一个仓库。选择一个仓库比较安全。</p>
<p><img src="/images/2019/utterances.png" alt="utterances"></p>
<p>安装完成就是配置成功了，是不是非常简单。</p>
<h2 id="使用-utterances">使用 utterances</h2>
<p>在你要使用评论的地方，插入以下代码：</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span><span class="lnt">3
</span><span class="lnt">4
</span><span class="lnt">5
</span><span class="lnt">6
</span><span class="lnt">7
</span></code></pre></td>
<td class="lntd">
<pre class="chroma"><code class="language-html" data-lang="html"><span class="p">&lt;</span><span class="nt">script</span> <span class="na">src</span><span class="o">=</span><span class="s">&#34;https://utteranc.es/client.js&#34;</span>
        <span class="na">repo</span><span class="o">=</span><span class="s">&#34;nusr/blog&#34;</span>
        <span class="na">issue-term</span><span class="o">=</span><span class="s">&#34;pathname&#34;</span>
        <span class="na">theme</span><span class="o">=</span><span class="s">&#34;github-light&#34;</span>  
        <span class="na">crossorigin</span><span class="o">=</span><span class="s">&#34;anonymous&#34;</span>
        <span class="na">async</span><span class="p">&gt;</span>
<span class="p">&lt;/</span><span class="nt">script</span><span class="p">&gt;</span>
</code></pre></td></tr></table>
</div>
</div><p><strong>nusr/blog</strong> 是你配置允许访问的仓库，格式为 <strong>user-name/repo-name</strong> 。</p>
<p>或者动态创建 script 标签：</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre class="chroma"><code><span class="lnt"> 1
</span><span class="lnt"> 2
</span><span class="lnt"> 3
</span><span class="lnt"> 4
</span><span class="lnt"> 5
</span><span class="lnt"> 6
</span><span class="lnt"> 7
</span><span class="lnt"> 8
</span><span class="lnt"> 9
</span><span class="lnt">10
</span><span class="lnt">11
</span><span class="lnt">12
</span><span class="lnt">13
</span><span class="lnt">14
</span><span class="lnt">15
</span></code></pre></td>
<td class="lntd">
<pre class="chroma"><code class="language-html" data-lang="html"><span class="p">&lt;</span><span class="nt">script</span> <span class="na">type</span><span class="o">=</span><span class="s">&#34;text/javascript&#34;</span><span class="p">&gt;</span>
    <span class="p">(</span><span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
        <span class="c1">// 匿名函数，防止污染全局变量
</span><span class="c1"></span>        <span class="kd">var</span> <span class="nx">utterances</span> <span class="o">=</span> <span class="nb">document</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s1">&#39;script&#39;</span><span class="p">);</span>
        <span class="nx">utterances</span><span class="p">.</span><span class="nx">type</span> <span class="o">=</span> <span class="s1">&#39;text/javascript&#39;</span><span class="p">;</span>
        <span class="nx">utterances</span><span class="p">.</span><span class="kr">async</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
        <span class="nx">utterances</span><span class="p">.</span><span class="nx">setAttribute</span><span class="p">(</span><span class="s1">&#39;issue-term&#39;</span><span class="p">,</span><span class="s1">&#39;pathname&#39;</span><span class="p">)</span>
        <span class="nx">utterances</span><span class="p">.</span><span class="nx">setAttribute</span><span class="p">(</span><span class="s1">&#39;theme&#39;</span><span class="p">,</span><span class="s1">&#39;github-light&#39;</span><span class="p">)</span>
        <span class="nx">utterances</span><span class="p">.</span><span class="nx">setAttribute</span><span class="p">(</span><span class="s1">&#39;repo&#39;</span><span class="p">,</span><span class="s1">&#39;nusr/blog&#39;</span><span class="p">)</span>
        <span class="nx">utterances</span><span class="p">.</span><span class="nx">crossorigin</span> <span class="o">=</span> <span class="s1">&#39;anonymous&#39;</span><span class="p">;</span>
        <span class="nx">utterances</span><span class="p">.</span><span class="nx">src</span> <span class="o">=</span> <span class="s1">&#39;https://utteranc.es/client.js&#39;</span><span class="p">;</span>
        <span class="c1">// content 是要插入评论的地方
</span><span class="c1"></span>        <span class="nb">document</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="s1">&#39;content&#39;</span><span class="p">).</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">utterances</span><span class="p">);</span>
    <span class="p">})();</span>
<span class="p">&lt;/</span><span class="nt">script</span><span class="p">&gt;</span>
</code></pre></td></tr></table>
</div>
</div><p>我的博客是使用 Hugo 搭建的，可以参考我的<a href="https://github.com/nusr/blog/blob/master/config.toml">配置 config.toml</a>。</p>
<h2 id="配置-utterances">配置 utterances</h2>
<p>utterances 可以配置主题，评论映射。</p>
<p>主题 <strong>theme</strong> 选项如下：</p>
<ol>
<li>github-light</li>
<li>github-dark</li>
<li>github-dark-orange</li>
<li>icy-dark</li>
<li>dark-blue</li>
<li>photon-dark</li>
</ol>
<p>评论 <strong>issue-term</strong> 映射配置选项如下：</p>
<ol>
<li>pathname</li>
<li>url</li>
<li>title</li>
<li>og:title</li>
<li>issue-number</li>
<li>specific-term</li>
</ol>
<p><a href="https://utteranc.es/">更多配置查看 https://utteranc.es/</a></p>
<blockquote>
<p>首发 <a href="https://nusr.github.io/">https://nusr.github.io/</a></p>
</blockquote>
  </div>

  <div class="post-copyright">
  <p class="copyright-item">
    <span class="item-title">文章作者</span>
    <span class="item-content">Luckly</span>
  </p>
  <p class="copyright-item">
    <span class="item-title">上次更新</span>
    <span class="item-content">
        2019-05-04
        
    </span>
  </p>
  
  
</div>
<footer class="post-footer">
    
    <nav class="post-nav">
      <a class="prev" href="/2019/05/react-%E7%8A%B6%E6%80%81%E7%AE%A1%E7%90%86%E7%BB%88%E7%BB%93%E7%AF%87/">
        <i class="iconfont icon-left"></i>
        <span class="prev-text nav-default">React 状态管理终结篇</span>
        <span class="prev-text nav-mobile">上一篇</span>
      </a>
      <a class="next" href="/2019/05/mac-os-%E7%89%88%E6%9C%AC%E4%BF%A1%E6%81%AF/">
        <span class="next-text nav-default"> Mac OS 版本信息</span>
        <span class="next-text nav-mobile">下一篇</span>
        <i class="iconfont icon-right"></i>
      </a>
    </nav>
  </footer>
  
</article>
            </div>
            

        </div>
    </main>

    <footer id="footer" class="footer">
        <div class="social-links">
  <a href="852851198@qq.com" class="iconfont icon-email" title="email" rel="noopener" target="_blank" data-title="email"> </a>
  <a href="https://github.com/ITmxs" class="iconfont icon-github" title="github" rel="noopener" target="_blank" data-title="github"> </a>
  <a href="https://juejin.cn/user/3843548384077192" class="iconfont icon-juejin" title="juejin" rel="noopener" target="_blank" data-title="juejin"> </a>
  <a href="https://www.zhihu.com/people/yimi-yang-guang-96-65" class="iconfont icon-zhihu" title="zhihu" rel="noopener" target="_blank" data-title="zhihu"> </a>
  <a href="https://space.bilibili.com/480883651" class="iconfont icon-bilibili" title="bilibili" rel="noopener" target="_blank" data-title="bilibili"> </a>
  <a href="https://luckly.work/index.xml" type="application/rss+xml" rel="noopener" target="_blank" class="iconfont icon-rss" title="rss"></a>


</div>

<div class="copyright">
  <span class="power-by">
    由 <a class="hexo-link" href="https://gohugo.io">Hugo</a> 强力驱动
  </span>
  <span class="division">|</span>
  <span class="theme-info">
    主题 -
    <a class="theme-link" href="https://github.com/olOwOlo/hugo-theme-even">Even</a>
  </span>

  <div class="busuanzi-footer">
    <span id="busuanzi_container_site_pv"> 本站总访问量 <span id="busuanzi_value_site_pv"><img src="/img/spinner.svg" alt="spinner.svg"/></span> 次 </span>
    <span class="division">|</span>
    <span id="busuanzi_container_site_uv"> 本站总访客数 <span id="busuanzi_value_site_uv"><img src="/img/spinner.svg" alt="spinner.svg"/></span> 人 </span>
  </div>

  <span class="copyright-year">
    &copy;
    2020 -
    2021
    <span class="heart">
      <i class="iconfont icon-heart"></i>
    </span>
    <span class="author">Luckly</span>
  </span>
</div>

    </footer>

    <div class="back-to-top" id="back-to-top">
        <i class="iconfont icon-up"></i>
    </div>
</div>
<script src="/lib/highlight/highlight.pack.js?v=20171001"></script>
  <script src="https://cdn.jsdelivr.net/npm/jquery@3.2.1/dist/jquery.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>
  <script src="https://cdn.jsdelivr.net/npm/slideout@1.0.1/dist/slideout.min.js" integrity="sha256-t+zJ/g8/KXIJMjSVQdnibt4dlaDxc9zXr/9oNPeWqdg=" crossorigin="anonymous"></script>
  <script src="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3.1.20/dist/jquery.fancybox.min.js" integrity="sha256-XVLffZaxoWfGUEbdzuLi7pwaUJv1cecsQJQqGLe7axY=" crossorigin="anonymous"></script>
<script type="text/javascript" src="/dist/even.47f727f4.min.js"></script>








</body>
</html>
